package com.wit.locker.controller;

import com.wit.locker.domain.ChargeScheme;
import com.wit.locker.domain.Location;
import com.wit.locker.domain.User;
import com.wit.locker.service.TestService;
import com.wit.locker.service.UserService;
import com.wit.locker.utils.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class LockerController {

    @Autowired
    private UserService userService;

    @Autowired
    private TestService testService;

    @PostMapping("/user_signin")
    @ResponseBody
    public BaseResponse<User> AuthUser(@ModelAttribute("user") User user) {
        BaseResponse<User> result = new BaseResponse<>();

        User u = userService.AuthUser(user);
        if(u != null) {
            result.code = 1;
            result.setData(u);
        }

        return result;
    }

    @GetMapping("/getLocation")
    public List<Location> getLocation() {
        return testService.getLocation();
    }

    @GetMapping("/getChargeScheme")
    public List<ChargeScheme> getChargeScheme() {
        return testService.getChargeScheme();
    }

}
